﻿Imports BUS
Imports DAO
Imports DTO
Imports DevComponents.DotNetBar

Public Class frmThayDoiQuiDinh

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnThayDoiQuiDinh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThayDoiQuiDinh.Click
        Dim dt As DataTable = ThamSoDAO.GetThamSoAll()
        Dim mathamso As Integer = Integer.Parse(dt.Rows(0).ItemArray(0).ToString())
        Dim ts As New ThamSoDTO()
        ts.MaThamSo = mathamso
        If chkChon.Checked = True Then
            ts.DieuKienThu = 1
        Else
            ts.DieuKienThu = 0
        End If
        Try
            ts.SoLuongNhapMin = UInt64.Parse(txtSoLuongSachNhoNhat.Text)
            ts.LuongTonMin = UInt64.Parse(txtDauSachCoSoLuongTonSauKhiBan.Text)
            ts.NoMin = UInt64.Parse(txtBanChoKHNoKhongQua.Text)
            ts.TonSauKhiBan = UInt64.Parse(txtSoLuongSachNhoNhat.Text)
        Catch e1 As FormatException
            MessageBoxEx.Show("Nhập vào giá trị là kiểu số")

        Catch e2 As OverflowException
            MessageBoxEx.Show("Số không được âm")
        End Try

        ThamSoDAO.Update(ts)
        MessageBoxEx.Show("Thay đổi thành công")
    End Sub

    Private Sub btnQuiDinhBanDau_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuiDinhBanDau.Click
        txtSoLuongSachNhoNhat.Text = "150"
        txtNhapSachTonItHon.Text = "300"
        txtBanChoKHNoKhongQua.Text = "20000"
        txtDauSachCoSoLuongTonSauKhiBan.Text = "20"
        chkChon.Checked = True
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtSoLuongSachNhoNhat.Clear()
        txtNhapSachTonItHon.Clear()
        txtBanChoKHNoKhongQua.Clear()
        txtDauSachCoSoLuongTonSauKhiBan.Clear()
        chkChon.Checked = False
    End Sub
End Class